package fun.qu_an.minecraft.fabric.fzbbl.util;

import net.fabricmc.fabric.mixin.object.builder.AbstractBlockAccessor;
import net.fabricmc.fabric.mixin.object.builder.AbstractBlockSettingsAccessor;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;

@SuppressWarnings({"unused"})
public class BlockUtils {
	public static AbstractBlockAccessor getAccessor(Block block) {
		return (AbstractBlockAccessor) block;
	}

	public static AbstractBlockSettingsAccessor getSettingsAccessor(Block block) {
		return (AbstractBlockSettingsAccessor) ((AbstractBlockAccessor) block).getSettings();
	}

	public static AbstractBlockSettingsAccessor getAccessor(AbstractBlock.Settings blockSettings) {
		return (AbstractBlockSettingsAccessor) blockSettings;
	}

	public static boolean isUnbreakable(Block block) {
		AbstractBlockSettingsAccessor accessor = (AbstractBlockSettingsAccessor) ((AbstractBlockAccessor) block).getSettings();
		return accessor.getHardness() <= -1.0f
			&& accessor.getResistance() >= 3600000.0f; // 必须用大于等于
	}
}
